#!/bin/sh /etc/rc.common
# Copyright (C) 2020 OpenWrt.org

START=95
PIDFILE=/tmp/run/atftpd.pid

start() {
	local enable
	local srv
	local port

	config_load atftpd

	config_get_bool enable service enable 0
	[ "$enable" -eq "0" ] && return 0

	config_get srv service path "/srv/tftp"
	config_get port service port 69

	atftpd --pidfile $PIDFILE --user root.root --port $port --daemon $srv
}

stop() {
	kill $(cat $PIDFILE)
}
